<?php
	class admin_system extends My_Controller
	{
		function admin_system()
		{
			parent::__construct();
			$this->check_login();
			$this->permiss_admin();
		}
		
		function index()
		{
			$data['title']			= 'Quản Lý Cấu Hình Website';
			$data['admin_config']	= $this->db->get_where('configs', array())->result_array();
			if ($this->input->post('cmd'))
			{
				$lock_web 	= 0;
				if ($this->input->post('lock_website')=="on")
				{
					$lock_web 	= 1;
				}
				$data	= array(
								'lock_web'				=> $lock_web,
								'message'				=> $this->input->post('message_lock_website'),
								'name_web'				=> $this->input->post('title_website'),
								'desc_web'				=> $this->input->post('desc_website'),
								'copyright'				=> $this->input->post('copyright'),
								'contact'				=> '',
								'keyword'				=> $this->input->post('key_word'),
								'quanity_support_yahoo'	=> '',
								'quanity_support_skype'	=> '',
								'com_name'				=> $this->input->post('com_name'),
								'com_address'			=> $this->input->post('com_address'),
								'logo'					=> $this->input->post('image'),
								'footer'				=> $this->input->post('footer'),
								'com_tel'				=> $this->input->post('com_tel'),
								'com_fax'				=> $this->input->post('com_fax'),
								'email'					=> $this->input->post('email'),
								'hotline'				=> $this->input->post('hotline'),
								'mobile'				=> $this->input->post('mobile'),
								'email_contact'			=> $this->input->post('email_contact'),
								'alexa_id'				=> $this->input->post('alexa_id'),
								'google_analytics'		=> $this->input->post('google_analytics'),
								'favicon'				=> $this->input->post('favicon')
				);
				$this->mod_lib->update('configs', array('id'=>$this->input->post('id')), $data);
				redirect(base_url().'admins/admin_system');
			}
			$data['content_admin']	= 'admins/admin_system/index';
			$this->load->view('admins/template_admin', $data);			
		}
		
		function delete_cache()
		{
			$this->load->helper('file');
			if(is_dir('application/cache/'))
			{
				@delete_files('application/cache/', true);
	   			@write_file('application/cache/index.html', '<p>Directory access is forbidden.</p>');
			}
			$this->check_logout();
		}
		
		function delete_captcha()
		{
	        if(is_dir('captcha/'))
			{
				@delete_files('captcha/', true);
	   			@write_file('captcha/index.html', '<p>Directory access is forbidden.</p>');
			}
			redirect($_SESSION['last_url_admin']);
		}
	}